package com.baor.controller;

import com.baor.domain.OrderVo;
import com.baor.feign.DistributionFeign;
import com.baor.service.OrderLogService;
import com.baor.service.OrderService;
import com.baor.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.Map;
import java.util.concurrent.TimeUnit;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;


    @RequestMapping("/orderList")
    public AjaxResult<?> orderList(@RequestBody Map<String, Object> params) {
        return this.orderService.orderList(params);
    }

    @RequestMapping("/orderInfo")
    public AjaxResult<?> orderInfo(@RequestBody Map<String, Object> params) {
        return this.orderService.orderInfo(params);
    }

    @RequestMapping("/orderRemark")
    public AjaxResult<?> orderRemark(@RequestBody Map<String, Object> params) {
        return this.orderService.orderRemark(params);
    }

    @RequestMapping("/orderSourceList")
    public AjaxResult<?> orderSourceList() {
        return this.orderService.orderSourceList();
    }

    @RequestMapping("/payMethodList")
    public AjaxResult<?> payMethodList() {
        return this.orderService.payMethodList();
    }

    @RequestMapping("/orderNotes")
    public AjaxResult<?> orderNotes(@RequestBody Map<String, Object> params) {
        return this.orderService.orderNotes(params);
    }

    @RequestMapping("/orderLogList")
    public AjaxResult<?> orderLogList(@RequestBody Map<String, Object> params) {
        return this.orderService.orderLogList(params);
    }

    @RequestMapping("/orderCodeList")
    public AjaxResult<?> orderCodeList() {
        return this.orderService.orderCodeList();
    }

    @RequestMapping("/orderStatusList")
    public AjaxResult<?> orderStatusList() {
        return this.orderService.orderStatusList();
    }

    @RequestMapping("/updateOrderStatus")
    public AjaxResult<?> updateOrderStatus(@RequestBody Map<String, Object> params) {

        return this.orderService.updateOrderStatus(params);
    }

    @RequestMapping("/addOrder")
    public AjaxResult<?> addOrder(@RequestBody Map<String, Object> params) {
        return this.orderService.addOrder(params);
    }
    @RequestMapping("/createDayEvent")
    public AjaxResult<?> createDayEvent(@RequestBody Map<String, Object> map) {
        return this.orderService.createUpdateOrderStatusEvent(map);
    }
    @RequestMapping("/createMinuteEvent")
    public AjaxResult<?> createMinuteEvent(@RequestBody Map<String, Object> map) {
        return this.orderService.minuteEvent(map);
    }
    @RequestMapping("/addOrderSetting")
    public AjaxResult<?> addOrderSetting(@RequestBody Map<String, Object> params) {
        return this.orderService.addOrderSetting(params);
    }
    @RequestMapping("/orderSettingList")
    public AjaxResult<?> orderSettingList(@RequestBody Map<String, Object> params) {
        return this.orderService.orderSettingList(params);
    }
    @RequestMapping("UpdateOrderBackEvent")
    public AjaxResult<?> UpdateOrderBackEvent(@RequestBody Map<String, Object> params) {
        return this.orderService.UpdateOrderBackEvent(params);
    }

    @Autowired
    private DistributionFeign feign;

        @RequestMapping("/updateOrderToLog")
    public AjaxResult updateOrderToLog(@RequestBody OrderVo vo){
        AjaxResult<?> ajaxResult = orderService.updateOrderToLog(vo);
            AjaxResult<?> ajaxResult1 = feign.disMoney(Integer.valueOf(ajaxResult.getData().toString()));
//            System.out.println(ajaxResult1);
            return ajaxResult;
    }

}
